'\" t
.\"     Title: gitnamespaces
.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 07/27/2015
.\"    Manual: Git Manual
.\"    Source: Git 2.5.0
.\"  Language: English
.\"
.TH "GITNAMESPACES" "7" "07/27/2015" "Git 2\&.5\&.0" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
gitnamespaces \- Git namespaces
.SH "SYNOPSIS"
.sp
.nf
GIT_NAMESPACE=<namespace> \fIgit upload\-pack\fR
GIT_NAMESPACE=<namespace> \fIgit receive\-pack\fR
.fi
.sp
.SH "DESCRIPTION"
.sp
Git supports dividing the refs of a single repository into multiple namespaces, each of which has its own branches, tags, and HEAD\&. Git can expose each namespace as an independent repository to pull from and push to, while sharing the object store, and exposing all the refs to operations such as \fBgit-gc\fR(1)\&.
.sp
Storing multiple repositories as namespaces of a single repository avoids storing duplicate copies of the same objects, such as when storing multiple branches of the same source\&. The alternates mechanism provides similar support for avoiding duplicates, but alternates do not prevent duplication between new objects added to the repositories without ongoing maintenance, while namespaces do\&.
.sp
To specify a namespace, set the GIT_NAMESPACE environment variable to the namespace\&. For each ref namespace, Git stores the corresponding refs in a directory under refs/namespaces/\&. For example, GIT_NAMESPACE=foo will store refs under refs/namespaces/foo/\&. You can also specify namespaces via the \-\-namespace option to \fBgit\fR(1)\&.
.sp
Note that namespaces which include a / will expand to a hierarchy of namespaces; for example, GIT_NAMESPACE=foo/bar will store refs under refs/namespaces/foo/refs/namespaces/bar/\&. This makes paths in GIT_NAMESPACE behave hierarchically, so that cloning with GIT_NAMESPACE=foo/bar produces the same result as cloning with GIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar\&. It also avoids ambiguity with strange namespace paths such as foo/refs/heads/, which could otherwise generate directory/file conflicts within the refs directory\&.
.sp
\fBgit-upload-pack\fR(1) and \fBgit-receive-pack\fR(1) rewrite the names of refs as specified by GIT_NAMESPACE\&. git\-upload\-pack and git\-receive\-pack will ignore all references outside the specified namespace\&.
.sp
The smart HTTP server, \fBgit-http-backend\fR(1), will pass GIT_NAMESPACE through to the backend programs; see \fBgit-http-backend\fR(1) for sample configuration to expose repository namespaces as repositories\&.
.sp
For a simple local test, you can use \fBgit-remote-ext\fR(1):
.sp
.if n \{\
.RS 4
.\}
.nf
git clone ext::\(aqgit \-\-namespace=foo %s /tmp/prefixed\&.git\(aq
.fi
.if n \{\
.RE
.\}
.sp
.SH "SECURITY"
.sp
Anyone with access to any namespace within a repository can potentially access objects from any other namespace stored in the same repository\&. You can\(cqt directly say "give me object ABCD" if you don\(cqt have a ref to it, but you can do some other sneaky things like:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  1." 4.2
.\}
Claiming to push ABCD, at which point the server will optimize out the need for you to actually send it\&. Now you have a ref to ABCD and can fetch it (claiming not to have it, of course)\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  2." 4.2
.\}
Requesting other refs, claiming that you have ABCD, at which point the server may generate deltas against ABCD\&.
.RE
.sp
None of this causes a problem if you only host public repositories, or if everyone who may read one namespace may also read everything in every other namespace (for instance, if everyone in an organization has read permission to every repository)\&.
